<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <title>{$admin.title} | {$admin.name|default='OneWeekBackend'}</title>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__ADMIN_PLUGINS__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__ADMIN_CSS__/login.css" media="all">

    <script type="text/javascript" src="__ADMIN_PLUGINS__/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN_PLUGINS__/layui/layui.js"></script>
    <script type="text/javascript" src="__ADMIN_JS__/admin.js"></script>
</head>

<body class="login-page">
    {if $login_config.background}

    <style>
        .login-page {
            background-color: #ececec;
            background-image: url('{$login_config.background}');
            background-repeat: no-repeat;
            background-size: cover;
            background-attachment: fixed;
            background-position: 50% 50%;
        }
    </style>
    {/if}

    <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login">
        <div class="login-content">
            <div class="login-thumb">
                <img src="__ADMIN_IMAGES__/thumb.jpg" alt="" srcset="">
            </div>
            <div class="layadmin-user-login-main " id="login-form">
                <div class="layadmin-user-login-box layadmin-user-login-header">
                    <h2>{$admin.name}</h2>
                    <p> </p>
                </div>
                <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                    <div class="layui-form-item">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                            for="LAY-user-login-username"></label>
                        <input type="text" name="username" autocomplete="off" id="LAY-user-login-username"
                            lay-verify="required" placeholder="用户名" class="layui-input">
                    </div>
                    <div class="layui-form-item">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                            for="LAY-user-login-password"></label>
                        <input type="password" name="password" autocomplete="off" id="LAY-user-login-password"
                            lay-verify="required" placeholder="密码" class="layui-input">
                    </div>

                    {if $login_config.token}
                    {:token_field()}
                    {/if}

                    {if $login_config.captcha==1}
                    {include file='auth/captcha' /}
                    {else/}
                    {if $login_config.captcha==2}
                    {include file='auth/gee_test' /}
                    {/if}
                    {/if}

                    <div class="layui-form-item">
                        <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="login-submit">登 入</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <style>
        .layui-layer-btn a {
            background-color: #1E9FFF !important;
            color: #fff;
        }
    </style>
    <script>
        var adminDebug = "{$debug}";

        layui.use(['form'], function () {
            var $ = layui.$
                , form = layui.form;
            //提交
            form.on('submit(login-submit)', function (data) {
                let loadT = layer.msg('正在登录', {
                    icon: 16,
                    time: 0,
                    shade: [0.3, "#000"],
                    scrollbar: false,
                });
                ajaxRequest({
                    host: "{:url('auth/login')}"
                    , method: 'post'
                    , data: data.field
                    , success: function (result) {
                        layer.close(loadT);
                        if (result.code == 200) {
                            layer.msg(result.msg, {
                                icon: 1,
                                time: 500,
                                scrollbar: false,
                            }, function () {
                                goUrl(result.url);
                            });
                        } else {
                            layer.msg(result.msg, {
                                icon: 5,
                                time: 800,
                                scrollbar: false,
                            }, function () {
                                refresh();
                            });

                        }
                    },
                    error: function (xhr) {
                        layer.close(loadT);

                        layer.msg('访问错误,代码' + xhr.status, {
                            icon: 2,
                            scrollbar: false,
                        });
                        refresh();

                    }
                });

            });

        });
        $(function () {
            $('#login-form').height($('.login-thumb img').height());
        });

        checkBrowser();

        /*检查浏览器*/
        function checkBrowser() {
            if (isIE()) {
                if (adminDebug) {
                    console.log('古代浏览器');
                }
                layer.open({
                    content: '请使用现代浏览器(谷歌浏览器、360极速或其他国产浏览器极速模式)操作本后台！',
                    icon: 5,
                    title: '警告',
                    btn: ['谷歌浏览器', '360极速浏览器', 'QQ浏览器'],
                    closeBtn: 0,
                    moveType: 1,
                    yes: function (index, layero) {
                        window.open('https://www.google.cn/chrome/');
                        return false;
                    }
                    , btn2: function (index, layero) {
                        window.open('https://browser.360.cn/ee/index.html');
                        return false;
                    }
                    , btn3: function (index, layero) {
                        window.open('https://browser.qq.com/');
                        return false;
                    }
                });
            } else {
                if (adminDebug) {
                    console.log('现代浏览器');
                }
            }
        }

        function isIE() {
            return !!window.ActiveXObject || "ActiveXObject" in window;
        }
    </script>
</body>
</html>